import { createRouter, createWebHistory } from 'vue-router'

const Login = () => import('@/views/login')

const Layout = () => import('@/views/Layout')

const Home = () => import('@/views/home')

const Pay = () => import('@/views/pay')

const Echarts = () => import('@/views/echarts')

const User = () => import('@/views/user')

const UserList = () => import('@/views/user/UserList')
const UserUpdate = () => import('@/views/user/UserUpdate')
const UserSetting = () => import('@/views/user/UserSetting')

const routes = [
	{
		// 一级路由 网站入口
		path: '/',
		redirect: '/login',
	},
	{
		// 登陆页面  一级路由
		path: '/login',
		name: 'login',
		component: Login,
	},
	{
		// 一级路由 布局入口
		path: '/Layout',
		name: 'Layout',
		component: Layout,
		// 二级路由
		children: [
			{
				// 首页
				path: '/home',
				component: Home,
			},
			{
				// 缴费管理
				path: '/pay',
				component: Pay,
			},
			{
				// 住户信息
				path: '/user',
				component: User,
				// 三级路由
				children: [
					{
						// 住户信息列表
						path: 'userList',
						component: UserList,
					},
					{
						// 住户信息修改
						path: 'userUpdate',
						component: UserUpdate,
					},
					{
						// 住户中心
						path: 'userSetting',
						component: UserSetting,
					},
				],
			},
			{
				// Echarts
				path: '/echarts',
				component: Echarts,
			},
		],
	},
]

const router = createRouter({
	// history 模式必须  后台配合 才可以  解决方案  收藏
	history: createWebHistory(process.env.BASE_URL),
	routes,
})

export default router
